// stores/fileTransStore.ts
import { validateNull } from "@/utils/validate";
import { defineStore } from "pinia";

export const useFileTransStore = defineStore("fileTransStore", {
  state: () => ({
    taskId: "" as string,
    autoChapters: [] as any[],
    keySentences: [] as any[],
    keywords: [] as string[],
    pptExtraction: {} as any,
    summarization: {} as any,
    transcription: {} as any,
    translation: {} as any,
    outputMp3Path: "" as string,
  }),
  actions: {
    setData(videoData: any) {
      if (!validateNull(videoData)) {
        const taskId = videoData?.TaskId || "";
        const autoChapters = videoData?.autoChapters?.AutoChapters || [];
        const keySentences
        = videoData?.meetingAssistance?.MeetingAssistance?.KeySentences || [];
        const keywords
        = videoData?.meetingAssistance?.MeetingAssistance?.Keywords || [];
        const pptExtraction
        = videoData?.pptExtraction?.PptExtraction || {};
        const summarization
        = videoData?.summarization?.Summarization || {};
        const transcription
        = videoData?.transcription?.Transcription || {};
        const translation = videoData?.translation?.Translation || {};
        const outputMp3Path = videoData?.outputMp3Path || "";

        this.taskId = taskId;
        this.autoChapters = autoChapters;
        this.keySentences = keySentences;
        this.keywords = keywords;
        this.pptExtraction = pptExtraction;
        this.summarization = summarization;
        this.transcription = transcription;
        this.translation = translation;
        this.outputMp3Path = outputMp3Path;
      }
      else {
        // console.log("No videoData found.");
      }
    },
  },

});
